package org.yefei.homeworkday15.six;

public class Circle extends Graphics {

	private double r;
	private final static double Pi = 3.14;


	public Circle(String type, double r) {
		super(type);
		this.r = r;
	}

	public double getR() {
		return r;
	}

	public void setR(double r) {
		if (r <= 0) {
			System.err.println("边长不能为非正数！");
			r = 4;
		}
		this.r = r;
	}

	public static double getPi() {
		return Pi;
	}


	@Override
	public void calPerimeter() {
		if (r > 0) {
		double zc = 2 * Pi * r;
			System.out.println(super.getType() + "的周长是：" + zc);
		} else {
			System.out.println("半径不能为负数和0！");
		}

	}

	@Override
	public void calArea() {
		if (r > 0) {
		double area = r * Pi * r;
			System.out.println(super.getType() + "的周长是：" + area);
		} else {
			System.out.println("半径不能为负数和0！");
		}

	}
}
